package com.example.demo.exception;

import lombok.Data;

/**
 * @author LF
 * @date 2021/4/21 - 13:50
 */
@Data
public class BizException extends RuntimeException{
    private static final long serialVersionUID = 1L;
    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public BizException() {
        super();
    }


    public BizException(BaseErrorInfoInterface errorInfoInterface) {
        super(errorInfoInterface.resultCode());
        this.errorCode = errorInfoInterface.resultCode();
        this.errorMsg = errorInfoInterface.resultMsg();
    }

    public BizException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
        super(errorInfoInterface.resultCode(), cause);
        this.errorCode = errorInfoInterface.resultCode();
        this.errorMsg = errorInfoInterface.resultMsg();
    }

    public BizException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BizException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
}
